#!/bin/bash
#获取当前目录下proto文件不带后缀的文件名
proto_files=$(ls *.proto | sed 's/\.proto$//')

echo ${proto_files}

#删除include目录和src目录下的pb.h和pb.cc文件
for proto_file in ${proto_files}
do
    rm -rf ../include/${proto_file}.pb.h ../src/${proto_file}.pb.cc
done



for proto_file in ${proto_files}
do
    protoc ${proto_file}.proto --cpp_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` &&\
    mv ${proto_file}.pb.h ../include/ && \
    mv ${proto_file}.grpc.pb.h ../include/ && \
    mv ${proto_file}.pb.cc ../src/ && \
    mv ${proto_file}.grpc.pb.cc ../src/
done